package com.bclz.environment;

import org.apache.hadoop.io.IntWritable;
import org.apache.hadoop.io.LongWritable;
import org.apache.hadoop.io.Text;
import org.apache.hadoop.mapreduce.Mapper;

import java.io.IOException;

public class EnvironmentMap extends Mapper<LongWritable,Text,Environment,IntWritable> {


    @Override
    protected void map(LongWritable key, Text value, Context context) throws IOException, InterruptedException {


        String[] split = value.toString().split(",");
        String year=split[0];
        String month=split[1];
        String temperature=split[3];

        context.write(new Environment(year+"-"+month,Integer.valueOf(temperature)),
                new IntWritable(Integer.parseInt(temperature)));

    }
}
